package com.boatAnchorAssistant.service.controller.web;

import com.boatAnchorAssistant.pojo.param.dataDictionaryType.*;
import com.boatAnchorAssistant.pojo.vo.dataDictionaryType.*;
import com.boatAnchorAssistant.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

import java.util.List;

/**
 *   web/数据字典类型
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 *
 */
@RestController
@RequestMapping("/dataDictionaryType/web")
public class DataDictionaryTypeWebController {

    private final DataDictionaryTypeService service;

    public DataDictionaryTypeWebController(DataDictionaryTypeService service) {
        this.service = service;
    }


    /**
     * 创建数据字典类型
     * @param param
     * @return
     */
    @PostMapping("/createDataDictionaryType")
    public ApiResult createDataDictionaryType(@RequestBody @Valid CreateDataDictionaryTypeParam param) {
        service.createDataDictionaryType(param);
        return ApiResult.ok();
    }


    /**
     * 修改数据字典类型
     * @param param
     */
    @PutMapping("/editDataDictionaryType")
    public ApiResult editDataDictionaryType(@RequestBody @Valid EditDataDictionaryTypeParam param) {
        service.editDataDictionaryType(param);
        return ApiResult.ok();
    }

    /**
     * 移除数据字典类型
     * @param id
     */
    @DeleteMapping("/removeDataDictionaryType")
    public ApiResult removeDataDictionaryType(@RequestParam("id") Long id) {
        service.removeDataDictionaryType(id);
        return ApiResult.ok();
    }

    /**
     * 启动/禁用数据字典类型
     * @param id
     */
    @GetMapping("/enabledDataDictionaryType")
    public ApiResult enabledDataDictionaryType(@RequestParam("id") Long id) {
        service.enabledDataDictionaryType(id);
        return ApiResult.ok();
    }

    /**
     * 获取数据字典类型详情
     * @param id
     * @return
     */
    @GetMapping("/getDataDictionaryType")
    public ApiResult<GetDataDictionaryTypeVo> getDataDictionaryType(@RequestParam("id") Long id) {
        GetDataDictionaryTypeVo vo = service.getDataDictionaryType(id);
        return ApiResult.ok(vo);
    }

    /**
     * 获取数据字典类型列表
     * @param param
     * @return
     */
    @PostMapping("/getDataDictionaryTypeList")
    public ApiResult<PageResult<GetDataDictionaryTypeListVo>> getDataDictionaryTypeList(@RequestBody GetDataDictionaryTypeListParam param) {
        PageResult<GetDataDictionaryTypeListVo> result = service.getDataDictionaryTypeList(param);
        return ApiResult.ok(result);
    }


    /**
     * 获取数据字典类型下拉列表
     *
     * @return
     */
    @PostMapping("/getDataDictionaryTypeDownList")
    public ApiResult<List<GetDataDictionaryTypeDownListVo>> getDataDictionaryTypeDownList(@RequestBody(required = false) @Valid GetDataDictionaryTypeDownListParam param) {
        List<GetDataDictionaryTypeDownListVo> list = service.getDataDictionaryTypeDownList(param);
        return ApiResult.ok(list);
    }


}

